const Router = require("koa-router");

const { auth, hadAdminPermission } = require("../middleware/auth.middleware");

const {
  create,
  update,
  remove,
  restore,
  findAll,
  findOne,
  findAllByUser,
  updateCategoryRecord
} = require("../controller/category.controller");

const router = new Router({ prefix: "/categories" });
// 更新浏览记录、点赞记录
router.put("/update/record/:id", auth, updateCategoryRecord);
// 获取详情
router.get("/:id", auth, findOne);

// 发布
router.post("/", auth, create);

// 修改接口
router.put("/update/:id", auth, hadAdminPermission, update);

// 删除 和 恢复
router.del("/:id/off", auth, remove);
router.del("/:id/on", auth, hadAdminPermission, restore);

// 获取列表
router.post("/list", auth,findAll);
// 获取用户自己的项目列表
router.post("/list/my", auth,findAllByUser);
// 用户访问接口
module.exports = router;
